<template>
	<view class="content">
		<u-navbar title="逛一逛" :border-bottom="false" back-icon-color="#ffffff" title-color="#fff" :background="{backgroundColor:'#000'}"></u-navbar>
		<view class="lists" v-for="(item,index) in list" @click="see(item.user_id)">
			<image :src="HOSTURL+item.user_head" mode="aspectFill"></image>
			<view class="text">				
				<view class="name">
					{{item.user_name}}
				</view>
				<view class="des">
					{{item.city}}|{{item.user_age}}岁|{{item.stature}}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				HOSTURL:this.$HOSTURL,
				sex:1,
				list:[],
				longitude: this.$store.state.longitude,
				latitude: this.$store.state.latitude,
				pagecount: 10,
				pagesize: 10,
				page: 0,
				total:null
			}
		},
		onLoad(options) {
			console.log(options.sex);
			this.sex = options.sex;
		},
		onShow() {
			this.getlist()
		},
		onReachBottom(){
			var that = this;
			let  allTotal = that.page * that.pagesize
				if(allTotal < that.total){
					//当前条数小于总条数 则增加请求页数
					that.page ++;
					uni.showLoading({
						title: '加载中'
					})
					setTimeout(function(){
						uni.hideLoading()
						that.getlist() //调用加载数据方法
					},500)
				}else{
					// console.log('已加载全部数据')
					uni.showToast({
						title:'已加载全部数据',
						icon:'none'
					})
				}
		},
		methods: {
			see(e){
				uni.navigateTo({
					url: '/pages/guangyiguang/details?id='+e,
				})
			},
			getlist(cb) {
				let that = this;
				uni.showLoading({
					title: '加载中'
				})
				uni.request({
					url: that.global.url + '/api/guangyiguang/lists',
					method: 'POST',
					header: {
						'content-type': 'application/x-www-form-urlencoded',
					},
					data: {
						sex: that.sex,
						longitude: that.longitude,
						latitude: that.latitude,
						page: that.page,
						size:that.pagesize
					},
					success: (res) => {
						console.log('首页数据')
						console.log(res)
						uni.hideLoading()
						if (res.data.code == 200) {
							that.total = res.data.result.total
							const newlist = res.data.result.data
							that.list.push(...newlist)
							// that.hotslist = res.data.data.hotslist
						} else {
							console.log(res);
						}
					}
				})
			}
		},
	}
</script>

<style lang="scss" scoped>
	.content {
		background: #2A2931;
		min-height: 100vh;
		.lists{
			width: 100%;
			margin-bottom: 3rpx;
			position: relative;
			color: #fff;
			font-size: 28rpx;
			
			.text{
				position: absolute;
				width: 100%;
				bottom: 20rpx;
				left: 30rpx;
			}
			image{
				width: 100%;
				border-radius: 10rpx;
			}
		}
	}
	
</style>